<?php
require_once "config.php";
$id = $_GET['id'];
$cate_name = $_POST['cate_name'];
$flag = $_POST['level'];
if($cate_name!=""){
    $sql = "update category set cate_name='{$cate_name}',flag={$flag} where id = $id";
    $rst = mysqli_query($con,$sql);
    $num = mysqli_affected_rows($con);
    if($num){
        echo "<script>alert('编辑成功!');window.location.href='cate_list.php';</script>";
    }else{
        echo "<script>alert('编辑失败,请重新输入');window.location.href='cate_edit.php?id={$id}';</script>";
    }
}else{
    echo "<script>alert('不能为空,请重新输入');window.location.href='cate_edit.php?id={$id}';</script>";
}